Package edu.claflin.finder.log
Class LogUtil
java.lang.Object
edu.claflin.finder.log.LogUtil
Logging utility for documenting the state of the program. This simple custom
built logging utility outputs to a file the steps involved in the program.
It may also be configured to output to the terminal as well.
- Version:
- 3.1 May 28, 2015
- Author:
- Charles Allen Schultz II
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BufferedWriterThe BufferedWriter used to log to a file.The HashMap used for determining which of the logging outputs are logged to a file.private booleanThe value representing if logging to a file is enabled.private booleanThe value representing if logging to the terminal is enabled.private final LogLevelThe maximum granularity of the logging utility.static StringTESTThe HashMap used for determining which of the logging outputs are logged to the terminal. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Destroys all logging functionality of the log engine.voidDestroys the Logging to File functionality of the log engine.voidDestroys the Logging to Terminal functionality of the log engine.private voidUsed to log data.voidLogs an ALGO message.voidLogs an ERROR message.voidLogs a GRPH message.voidLogs an INFO message.private voidreportProblem(String problem, String solution) Used to report problems with the logging engine to the terminal.private voidsetFileLogs(boolean[] fileLogs) Sets the FileLogs HashMap for selective logging to the file.private voidsetTerminalLogs(boolean[] terminalLogs) Sets the TerminalLogs HashMap for selective terminal logging.
-
Field Details
-
path
TEST -
bW
The BufferedWriter used to log to a file. -
logToFile
private boolean logToFileThe value representing if logging to a file is enabled. Defaults to true and is only set to false due to a malfunction in the BufferedWriter. -
logToTerminal
private boolean logToTerminalThe value representing if logging to the terminal is enabled. Defaults to true. -
maxGranularity
The maximum granularity of the logging utility. Anything greater will be ignored. -
terminalLogs
The HashMap used for determining which of the logging outputs are logged to the terminal. -
fileLogs
The HashMap used for determining which of the logging outputs are logged to a file.
-
-
Constructor Details
-
LogUtil
Constructs the logging utility.- Parameters:
maxGranularity- the maximum granularity of the log messages.fileLogs- the boolean array containing four values.terminalLogs- the boolean array containing four values.
-
LogUtil
Constructs the logging utility. Allows the user to specify which outputs are logged to the terminal and which are logged to the file.- Parameters:
maxGranularity- the maximum granularity of the log messages.logToTerminal- the boolean value indicating if logging to terminal should be enabled.
-
-
Method Details
-
setFileLogs
private void setFileLogs(boolean[] fileLogs) Sets the FileLogs HashMap for selective logging to the file.- Parameters:
fileLogs- the boolean array containing four values.
-
setTerminalLogs
private void setTerminalLogs(boolean[] terminalLogs) Sets the TerminalLogs HashMap for selective terminal logging.- Parameters:
terminalLogs- the boolean array containing four values.
-
destroyLogToFile
public void destroyLogToFile()Destroys the Logging to File functionality of the log engine. Sets to false the boolean value indicating that logging to a file is enabled. It also closes the BufferedWriter to free the resource. -
destroyLogToTerminal
public void destroyLogToTerminal()Destroys the Logging to Terminal functionality of the log engine. Sets to false the boolean value indicating that logging to the terminal is enabled. -
destroy
public void destroy()Destroys all logging functionality of the log engine. A convenience method that calls both destroyLogToTerminal() and destroyLogToFile(). -
reportProblem
Used to report problems with the logging engine to the terminal. Reporting is done to the terminal since most likely the BufferedWriter is experiencing an error.- Parameters:
problem- the String representing the problem that occurred.solution- the String representing the solution the program utilized.
-
log
Used to log data. Contains the logic for logging both to the terminal and to a file. This method is private so that a user may not pass incorrectLogTypeobjects to the method. Instead, there exist public methods that call this method appropriately.- Parameters:
type- the LogType object representing the level of detail for the log.granularity- the LogLevel object representing how granular this message is.detail- the String representing the data to be logged.
-
logError
Logs an ERROR message. Used by the user to log error messages. Calls log(LogType, LogLevel, String) for the user.- Parameters:
level- the level of granularity of this message.detail- the String representing the data to be logged.
-
logInfo
Logs an INFO message. Used by the user to log info messages. Calls log(LogLevel, String) for the user.- Parameters:
level- the level of granularity of this message.detail- the String representing the data to be logged.
-
logAlgo
Logs an ALGO message. Used by the user to log algorithm messages. Calls log(LogLevel, String) for the user.- Parameters:
level- the level of granularity of this message.detail- the String representing the data to be logged.
-
logGraph
Logs a GRPH message. Used by the user to log graph messages. Calls log(LogLevel, String) for the user.- Parameters:
level- the level of granularity of this message.detail- the String representing the data to be logged.
-